<template>
  <div class="flex_cm container" style="height: 100%">
    <search
      :data="header_list"
      @changeIsShow="
        (e) => {
          header_list[e].isShow = !header_list[e].isShow
          header_list[e].value =
            header_list[e].type == 'input_number' ? ['', ''] : ''
        }
      "
      @search="search_key"
      @reset="
        header_list.forEach((item) => {
          item.value =
            item.label == '升级类型'
              ? ['', '']
              : item.type == 'input_number'
              ? ['', '']
              : ''
        }),
          search_key()
      "
    ></search>
    <div class="p_0_10 bg_fff flex1">
      <div class="flex_js p_10_0">
        <div class="c_666 fw" v-if="route.name == 'upgradePrice'">
          铝模平台升级套餐
        </div>
        <div class="c_666 fw" v-if="route.name == 'szlsUpgradePrice'">
          数字孪生升级套餐
        </div>
        <div class="flex">
          <el-button
            type="primary"
            v-if="role_list[3].has_role"
            @click=";(show_box = true), get_project_list()"
            >新增</el-button
          >

          <setTable
            :data="header_list"
            :height_size="height_size"
            @changeShowTable="
              (e) => {
                header_list[e].showTable = !header_list[e].showTable
              }
            "
            @resetTableSet="
              () => {
                header_list.forEach((item) => {
                  item.showTable = true
                })
              }
            "
            @changeHeightSize="
              (e) => {
                height_size = e
              }
            "
          ></setTable>
        </div>
      </div>
      <el-table
        style="text-align: center"
        :data="list"
        :max-height="max_height"
        border
        highlight-current-row
        v-loading="loading"
        :default-sort="{ prop: 'code', order: 'descending' }"
        :row-style="{
          height: height_size == 2 ? '50px' : '',
        }"
        :cell-style="{
          padding: height_size == 3 ? '0' : '',
        }"
      >
        <el-table-column
          type="index"
          label="序号"
          width="80px"
        ></el-table-column>
        <el-table-column
          v-if="header_list[0].showTable"
          label="套餐单号"
          prop="code"
          sortable
          width="200px"
        ></el-table-column>
        <el-table-column
          label="套餐名称"
          prop="name"
          sortable
          v-if="header_list[1].showTable"
        >
          <template #default="scope: any">
            <div class="text_over" style="width: 100%">
              <el-tooltip :content="scope.row.name" placement="bottom">
                {{ scope.row.name }}
              </el-tooltip>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          v-if="header_list[2].showTable"
          label="申请人"
          sortable
          prop="applyManagerUserName"
        >
        </el-table-column>
        <el-table-column
          label="套餐申请日期"
          sortable
          prop="applyTime"
          v-if="header_list[3].showTable"
        >
          <template #default="scope: any">
            <div>
              {{ formatDate(parseInt(scope.row.applyTime), 'yyyy-MM-dd') }}
            </div>
          </template>
        </el-table-column>

        <el-table-column
          label="套餐启用日期"
          sortable
          prop="enableTime"
          v-if="header_list[4].showTable"
        >
          <template #default="scope: any">
            <div>
              {{ formatDate(parseInt(scope.row.enableTime), 'yyyy-MM-dd') }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          v-if="header_list[5].showTable"
          label="升级类型"
          sortable
          prop="oldLevelId"
          width="220px"
        >
          <template #default="scope: any">
            <div>
              <span v-for="(item, index) in enterprise_level_list" :key="index"
                ><span v-show="scope.row?.oldLevelId == item.id">{{
                  item.name
                }}</span></span
              >
              -
              <span v-for="(item, index) in enterprise_level_list" :key="index"
                ><span v-show="scope.row?.newLevelId == item.id">{{
                  item.name
                }}</span></span
              >
            </div>
          </template>
        </el-table-column>
        <el-table-column
          v-if="header_list[6].showTable"
          label="升级价格"
          prop="price"
          sortable
        ></el-table-column>
        <el-table-column
          label="备注"
          prop="remark"
          sortable
          v-if="header_list[7].showTable"
        >
          <template #default="scope: any">
            <div class="text_over" style="width: 100%">
              <el-tooltip :content="scope.row.remark" placement="bottom">
                {{ scope.row.remark }}
              </el-tooltip>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="124px">
          <template #default="scope: any">
            <table_edit
              v-show="scope.row?.status == 1"
              :role="role_list"
              @edit_item_status="exam_list(scope)"
              @edit_item="update_list(scope)"
              @delete_item="delete_list(scope)"
            ></table_edit>
            <el-tooltip
              v-show="scope.row?.status != 1 && (role_list[4] as any).has_role"
              content="详情"
              placement="bottom"
            >
              <svgBtn
                icon="table_info"
                style="font-size: 20px"
                @click="exam_list(scope)"
              ></svgBtn>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        class="m_10_0 pagination"
        v-model:currentPage="form_data.current"
        v-model:page-size="form_data.pageSize"
        :page-sizes="[5, 10, 20, 50]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="
          (e) => {
            form_data.pageSize = e
            get_list()
          }
        "
        @current-change="
          (e) => {
            form_data.current = e
            get_list()
          }
        "
      />
    </div>
  </div>
  <el-drawer
    v-model="show_box"
    direction="rtl"
    @close="resetForm(addupgradePackageform)"
    size="60%"
    destroy-on-close
    :close-on-click-modal="false"
  >
    <template #title>
      <h4 v-if="is_exam">审核</h4>
      <div v-else>
        <h4 v-if="add_form_data.id == ''">新增升级套餐</h4>
        <h4 v-else>编辑升级套餐</h4>
      </div>
    </template>
    <template #default>
      <el-form
        :model="add_form_data"
        :rules="(rules as any)"
        label-width="120px"
        ref="addupgradePackageform"
      >
        <div class="flex_wp">
          <el-form-item label="申请日期" style="width: 50%" prop="applyTime">
            <el-date-picker
              v-model="add_form_data.applyTime"
              type="date"
              format="YYYY-MM-DD"
              value-format="x"
              placeholder="请选择申请日期"
              :disabled="is_exam"
              :disabled-date="disabledApply"
              @change="
                () => {
                  add_form_data.enableTime =
                    add_form_data.enableTime < add_form_data.applyTime
                      ? ''
                      : add_form_data.enableTime
                }
              "
            />
          </el-form-item>
          <el-form-item
            label="套餐启用日期"
            style="width: 50%"
            prop="enableTime"
          >
            <el-date-picker
              v-model="add_form_data.enableTime"
              type="date"
              format="YYYY-MM-DD"
              value-format="x"
              placeholder="请选择启用日期"
              :disabled="is_exam || add_form_data.applyTime == ''"
              :disabled-date="disabledEnable"
            />
          </el-form-item>
          <el-form-item label="名称" style="width: 50%" prop="name">
            <el-input
              placeholder="请输入"
              v-model="add_form_data.name"
              :disabled="is_exam"
              show-word-limit
              maxlength="30"
            >
            </el-input>
          </el-form-item>
          <div style="width: 50%" class="flex">
            <el-form-item label="升级类型" prop="oldLevelId">
              <el-select
                v-model="add_form_data.oldLevelId"
                placeholder="请选择初始等级"
                :disabled="is_exam"
              >
                <el-option
                  :disabled="
                    add_form_data.newLevelId != '' &&
                    item.id >= add_form_data.newLevelId
                  "
                  v-for="(item, index) in enterprise_level_list"
                  :key="index"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
            <span class="m_0_10">-</span>
            <el-form-item label-width="0" prop="newLevelId">
              <el-select
                v-model="add_form_data.newLevelId"
                placeholder="请选择最终等级"
                :disabled="is_exam"
              >
                <el-option
                  v-for="(item, index) in enterprise_level_list"
                  :key="index"
                  :disabled="
                    item.id <= add_form_data.oldLevelId ||
                    add_form_data.oldLevelId == ''
                  "
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </div>
          <el-form-item label="升级价格" style="width: 50%" prop="price">
            <el-input
              placeholder="请输入"
              @input="
                add_form_data.price = add_form_data.price.replace(
                  /^(0+)|[^\d]+/g,
                  ''
                )
              "
              v-model="add_form_data.price"
              :disabled="is_exam"
              show-word-limit
              maxlength="9"
            >
            </el-input>
          </el-form-item>
          <el-form-item label="套餐类型">
            <el-radio
              :label="true"
              :disabled="is_exam"
              v-model="add_form_data.isBase"
              >通用</el-radio
            >
            <el-radio
              :label="false"
              :disabled="is_exam"
              v-model="add_form_data.isBase"
              >特殊（指定时间段优先使用）</el-radio
            >
          </el-form-item>
        </div>
        <el-form-item label="适用时间" prop="upgradePackageTimeList">
          <div>
            <div style="color: #606266">套餐使用时间段 (不包含结束日当天)</div>
            <div
              v-for="(item, index) in add_form_data.upgradePackageTimeList"
              class="flex m_bottom10"
            >
              <el-date-picker
                :disabled="is_exam"
                v-model="item.time"
                type="daterange"
                format="YYYY-MM-DD"
                value-format="x"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              />
              <el-tooltip
                v-if="index > 0 && !is_exam"
                content="删除"
                placement="bottom"
                ><svgBtn
                  @click="add_form_data.upgradePackageTimeList.splice(index, 1)"
                  icon="user_reduce"
                  style="font-size: 24px; margin: 0 0 0 15px"
                ></svgBtn
              ></el-tooltip>
              <el-tooltip
                content="添加"
                placement="bottom"
                v-if="
                  index == add_form_data.upgradePackageTimeList.length - 1 &&
                  !is_exam
                "
              >
                <svgBtn
                  @click="
                    add_form_data.upgradePackageTimeList.push(
                      JSON.parse(JSON.stringify(time_item))
                    )
                  "
                  icon="user_add"
                  style="font-size: 24px; margin: 0 15px"
                ></svgBtn>
              </el-tooltip>
            </div>
          </div>
        </el-form-item>
        <el-form-item label="备注">
          <el-input
            placeholder="请输入"
            v-model="add_form_data.remark"
            type="textarea"
            rows="2"
            :disabled="is_exam"
            show-word-limit
            maxlength="300"
          >
          </el-input>
        </el-form-item>
        <el-table
          :data="project_list"
          style="text-align: center"
          border
          class="coordinate"
          max-height="300"
        >
          <el-table-column
            label="序号"
            type="index"
            width="80px"
          ></el-table-column>
          <el-table-column
            label="赠品信息"
            prop="name"
            width="100px"
          ></el-table-column>
          <el-table-column label="计量方式" prop="name" width="100px">
            <template #default="scope: any">
              <div v-for="(item, index) in measurement_list" :key="index">
                <span v-if="item.dictCode == scope.row.type">{{
                  item.dictValue
                }}</span>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="赠品数量" prop="name" width="100px">
            <template #default="scope: any">
              <el-input
                placeholder="请输入"
                @input="
                  scope.row.giftQuantity = scope.row.giftQuantity.replace(
                    /^(0+)|[^\d]+/g,
                    ''
                  )
                "
                v-model="scope.row.giftQuantity"
                :disabled="is_exam"
              ></el-input>
            </template>
          </el-table-column>
          <el-table-column label="有限时长" prop="name" width="250px">
            <template #default="scope: any">
              <div class="flex">
                <el-input
                  placeholder="请输入"
                  v-model="scope.row.duration"
                  @input="
                    scope.row.duration = scope.row.duration.replace(
                      /^(0+)|[^\d]+/g,
                      ''
                    )
                  "
                  :disabled="is_exam"
                ></el-input>
                <el-select
                  v-model="scope.row.durationType"
                  style="margin-left: 10px"
                  :disabled="is_exam"
                >
                  <el-option
                    v-for="(item, index) in durctionTpye_list"
                    :key="index"
                    :label="item.dictValue"
                    :value="parseInt(item.dictCode)"
                  ></el-option>
                </el-select>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="备注">
            <template #default="scope: any">
              <el-input
                placeholder="请输入"
                v-model="scope.row.remark"
                :disabled="is_exam"
                show-word-limit
                maxlength="30"
              ></el-input>
            </template>
          </el-table-column>
        </el-table>
        <div class="tr m_top10">
          <el-button @click="resetForm(addupgradePackageform)">取消</el-button>
          <el-button
            type="primary"
            @click="submit(addupgradePackageform)"
            v-if="!is_exam && add_form_data.status != '2'"
            >保存</el-button
          >
          <el-button
            type="primary"
            @click="exam_submit"
            v-if="is_exam && add_form_data.status == '1'"
            >审核</el-button
          >
        </div>
      </el-form>
    </template>
  </el-drawer>
  <dialog_box
    @submit_delete="submit_delete"
    @close="show_delete_box = false"
    :show_delete_box="show_delete_box"
    :delete_name="delete_name"
  ></dialog_box>
</template>

<script lang="ts" setup>
import {
  check_role,
  formatDate,
  dictData,
  handle_search_key,
} from '@/utils/utils' // 权限校验
import search from '@/view/components/search.vue'
import dialog_box from '@/view/components/dialog_box.vue'
import table_edit from '@/view/components/table_edit.vue'
import svgBtn from '@/components/svg_button.vue'
import setTable from '@/view/components/setTable.vue'
import { onMounted, ref, onUnmounted, nextTick, computed } from 'vue'
import { FormInstance, ElMessage, ElMessageBox } from 'element-plus'
import axios from '@/service/HttpRequest'
import serviceApi from '@/service/api'
import EventBus from '@/utils/EventBus'
import { useStore } from 'vuex'
import { useRoute } from 'vue-router'
const store = useStore()
const route = useRoute()
// type FormInstance = InstanceType<typeof ElForm>
const addupgradePackageform = ref<FormInstance>()
const checkUpgradePackageTimeList = (rule, value, callback) => {
  console.log(value)
  if (value[0].time == '' || value[0].time === null) {
    return callback(new Error('请选择适用时间！'))
  } else {
    callback()
  }
}
const rules = ref({
  name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
  applyTime: [
    {
      type: 'date',
      required: true,
      message: '请选择申请时间',
      trigger: 'change',
    },
  ],
  enableTime: [
    {
      type: 'date',
      required: true,
      message: '请选择启用日期',
      trigger: 'change',
    },
  ],
  upgradePackageTimeList: [
    {
      required: true,
      validator: checkUpgradePackageTimeList,
      trigger: 'change',
    },
  ],
  oldLevelId: [
    { required: true, message: '请选择初始等级', trigger: 'change' },
  ],
  newLevelId: [
    { required: true, message: '请选择最终等级', trigger: 'change' },
  ],
  price: [{ required: true, message: '请输入价格', trigger: 'blur' }],
})
const disabledApply = (time) => {
  return time.getTime() < Date.now() - 8.64e7
}
const disabledEnable = (time) => {
  return time.getTime() < add_form_data.value.applyTime
}
const role_list = ref([
  { path: 'upgradePrice/pass', has_role: false },
  { path: 'upgradePrice/edit', has_role: false },
  { path: 'upgradePrice/delete', has_role: false },
  { path: 'upgradePrice/post', has_role: false },
  { path: 'upgradePrice/info', has_role: false },
])
const max_height = ref()
nextTick(() => {
  max_height.value = window.innerHeight - 320 // 不带分页的 table 高度
  role_list.value.forEach((item) => {
    item.has_role = check_role(item.path)
  })
})

const list = ref()
const total = ref()
const project_list = ref([])
const loading = ref(false)
const show_box = ref(false)
const enterprise_level_list = ref()
const height_size = ref(1)
const header_list = ref<any>([
  {
    label: '套餐单号',
    value: '',
    showTable: true,
    type: 'input',
    isShow: true,
    options: [],
  },
  {
    label: '套餐名称',
    value: '',
    showTable: true,
    type: 'input',
    isShow: true,
    options: [],
  },
  {
    label: '申请人',
    value: '',
    showTable: true,
    type: 'input',
    isShow: false,
    options: [],
  },
  {
    label: '套餐申请日期',
    value: '',
    showTable: true,
    type: 'date',
    isShow: false,
    options: [],
  },
  {
    label: '套餐启用日期',
    value: '',
    showTable: true,
    type: 'date',
    isShow: false,
    options: [],
  },
  {
    label: '升级类型',
    value: ['', ''],
    showTable: true,
    type: '*select',
    isShow: false,
    options: computed(() => {
      return enterprise_level_list.value
    }),
  },
  {
    label: '升级价格',
    value: ['', ''],
    showTable: true,
    type: 'input_number',
    isShow: false,
    options: [],
  },
  {
    label: '备注',
    value: '',
    showTable: true,
    type: 'input',
    isShow: false,
    options: [],
  },
])
const form_data = ref({
  current: 1,
  pageSize: 10,
  applicant: '',
  code: '',
  name: '',
  price: '',
  applyTime: '',
  enableTime: '',
  oldLevelId: '',
  newLevelId: '',
  remark: '',
})
var time_item = ref({ time: '' })
const add_form_data = ref({
  id: '',
  applicant: store.state.user_info.id,
  applyName: store.state.user_info.username,
  name: '',
  oldLevelId: '',
  newLevelId: '',
  applyTime: '',
  enableTime: '',
  remark: '',
  price: '',
  isBase: true,
  upgradePackageItemList: [],
  upgradePackageTimeList: [JSON.parse(JSON.stringify(time_item.value))],
  status: '',
  productId: '',
})
const durctionTpye_list = ref() // 时长类型
const measurement_list = ref() // 计量方式
onMounted(() => {
  console.log(route.name)
  // 根据产品 区分
  if (route.name == 'szlsUpgradePrice') {
    // 数字孪生
    add_form_data.value.productId = '4'
  } else if (route.name == 'upgradePrice') {
    // 铝模
    add_form_data.value.productId = '2'
  }
  console.log(add_form_data.value)
  EventBus.on('refresh', () => {
    get_list()
    get_project_list()
    get_enterprise_level_list()
    ElMessage.success('刷新成功！')
  })
  get_list()
  get_project_list()
  get_enterprise_level_list()
  dictData('1514912374253948929').then((res) => {
    durctionTpye_list.value = res as any
  }) // 获取字典值  // 时长类型
  dictData('1511538556160180226').then((res) => {
    measurement_list.value = res as any
  }) // 获取字典值  // 计量方式
})
onUnmounted(() => {
  EventBus.off('refresh')
})

const update_list = (e) => {
  get_current_item(e.row.id)
}
const get_current_item = (e) => {
  axios
    .request({
      url: serviceApi.upgradePackage_curd + '/' + e,
      method: 'get',
    })
    .then((res) => {
      console.log(res)
      add_form_data.value = {
        id: res.data.id,
        applicant: res.data.applyManagerUserInfo.id,
        applyName: res.data.applyManagerUserInfo.name,
        name: res.data.name,
        oldLevelId: res.data.oldLevelId,
        newLevelId: res.data.newLevelId,
        applyTime: parseInt(res.data.applyTime) as any,
        enableTime: parseInt(res.data.enableTime) as any,
        remark: res.data.remark,
        price: res.data.price,
        status: res.data.status,
        upgradePackageItemList: [],
        upgradePackageTimeList: [],
        isBase: res.data.isBase,
        productId: add_form_data.value.productId,
      }
      if (res.data.upgradePackageTimeList.length) {
        res.data.upgradePackageTimeList.forEach((item) => {
          let a = []
          a[0] = parseInt(item.startTime)
          a[1] = parseInt(item.endTime)
          let b = { time: a }
          add_form_data.value.upgradePackageTimeList.push(b)
        })
      }
      console.log(add_form_data.value)
      project_list.value.forEach((element) => {
        res.data.upgradePackageItemList.some((item) => {
          if (element.id == item.itemId) {
            element = Object.assign(element, item)
          }
        })
      })
      show_box.value = true
    })
    .catch((error) => {
      ElMessage.error(error)
    })
}
const is_exam = ref(false)
const exam_list = (e) => {
  is_exam.value = true
  get_current_item(e.row.id)
}
const exam_submit = () => {
  ElMessageBox.confirm('确定审核通过该升级套餐设置？', '提示', {
    cancelButtonText: '取消',
    confirmButtonText: '确定',
    closeOnClickModal: false,
    type: 'warning',
  })
    .then(() => {
      axios
        .request({
          url: serviceApi.upgradePackage_pass + '/' + add_form_data.value.id,
          method: 'put',
        })
        .then((res) => {
          console.log(res)
          ElMessage.success('审核成功！')
          setTimeout(() => {
            show_box.value = false
            get_list()
          }, 1000)
        })
        .catch((error) => {
          ElMessage.error(error)
        })
    })
    .catch(() => {})
}
const show_delete_box = ref(false)
const delete_id = ref()
const submit_delete = () => {
  axios
    .request({
      url: serviceApi.upgradePackage_curd + '/' + delete_id.value,
      method: 'delete',
    })
    .then((res) => {
      console.log(res)
      ElMessage.success('删除成功！')
      setTimeout(() => {
        show_delete_box.value = false
        get_list()
      }, 1000)
    })
    .catch((error) => {
      ElMessage.error(error)
    })
}
const delete_name = ref()
const delete_list = (e) => {
  delete_id.value = e.row.id
  delete_name.value = e.row.code
  show_delete_box.value = true
}
const submit = async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate((valid) => {
    if (valid) {
      //   if (add_form_data.value.upgradePackageTimeList[0].time.length == 0) {
      //     ElMessage.error('请选择套餐使用时间段')
      //     return
      //   }
      add_form_data.value.upgradePackageTimeList.forEach((item) => {
        item.startTime = item.time[0]
        item.endTime = item.time[1]
      })
      add_form_data.value.upgradePackageItemList = project_list.value
      var data = add_form_data.value
      axios
        .request({
          url:
            data.id == ''
              ? serviceApi.upgradePackage_curd
              : serviceApi.upgradePackage_curd + '/' + data.id,
          method: data.id == '' ? 'post' : 'put',
          data: data,
        })
        .then((res) => {
          ElMessage.success('操作成功！')
          setTimeout(() => {
            show_box.value = false
            get_list()
          }, 1000)
        })
        .catch((error) => {
          ElMessage.error(error)
        })
    }
  })
}
const get_enterprise_level_list = () => {
  axios
    .request({
      url: serviceApi.enterprise_level_list,
      method: 'post',
    })
    .then((res) => {
      res.data.splice(res.data.length - 1, 4)
      enterprise_level_list.value = res.data
    })
    .catch((error) => {
      ElMessage.error(error)
    })
}
const get_project_list = () => {
  axios
    .request({
      url: serviceApi.project_list,
      method: 'post',
    })
    .then((res) => {
      res.data.forEach((element) => {
        element.giftQuantity = ''
        element.duration = ''
        element.durationType = 1
        element.itemId = element.id
      })
      res.data.splice(0, 1) // 去掉赠送金额
      project_list.value = res.data
    })
    .catch((error) => {
      ElMessage.error(error)
    })
}
const get_list = () => {
  loading.value = true
  let data = Object.assign(handle_search_key(form_data.value), {
    productId: {
      detailList: [{ value: add_form_data.value.productId }],
      type: 'INNER_LIKE',
    },
  })
  axios
    .request({
      url: serviceApi.upgradePackage_list,
      method: 'post',
      data: data,
    })
    .then((res) => {
      console.log(res)
      list.value = res.data.content
      total.value = parseInt(res.data.totalElements)
      loading.value = false
    })
    .catch((error) => {
      ElMessage.error(error)
    })
}
const search_key = () => {
  form_data.value = {
    current: 1,
    pageSize: 10,
    code: header_list.value[0].value + '',
    name: header_list.value[1].value + '',
    applicant: header_list.value[2].value as any,
    applyTime: header_list.value[3].value as any,
    enableTime: header_list.value[4].value as any,
    oldLevelId: header_list.value[5].value[0],
    newLevelId: header_list.value[5].value[1],
    price: header_list.value[6].value,
    remark: header_list.value[7].value.toString(),
  }
  get_list()
}
const resetForm = (formEl: FormInstance | undefined) => {
  if (!formEl) return
  formEl.resetFields()
  add_form_data.value = {
    id: '',
    applicant: store.state.user_info.id,
    applyName: store.state.user_info.username,
    name: '',
    oldLevelId: '',
    newLevelId: '',
    applyTime: '',
    enableTime: '',
    remark: '',
    price: '',
    status: '',
    isBase: true,
    upgradePackageItemList: [],
    upgradePackageTimeList: [JSON.parse(JSON.stringify(time_item.value))],
    productId: add_form_data.value.productId,
  }
  is_exam.value = false
  show_box.value = false
}
</script>

<style lang="scss" scoped>
:deep(.coordinate) {
  .el-input__inner {
    padding-right: 11px !important;
  }
}
</style>
